home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Singles Flirt Up Your Life! (German)
/
Singles Flirt Up Your Life.iso
/
data1.cab
/
Statemachine
/
sofa.lua
< prev
next >
Wrap
Text File
|
2004-01-29
|
5KB
|
147 lines
-- sofa state machine
beginStateMachine()
onMsg("buildMenu", function(msg)
if (repairMenu()) then return end
-- build the pie menu
clearPieMenu();
local button ;
button = addPieMenuButton("pm_sleepSofa", "nap");
button.addDescription(ACTIVITY, "nap");
button = addPieMenuButton("pm_sitdown", "sit");
button.addDescription(ACTIVITY, "sit");
local character = getStateObjectFromID(msg.sender);
if (not isUser(character, this, {"sit"})) then
local otherUsers = getOtherUsers(character, this, "sit")
if (getn(otherUsers) > 0) then
local characterOnSofa = otherUsers[1];
if activityPossible(character, "kissIntimate", characterOnSofa) then
button = addPieMenuButton("pm_getIntimateSofa", "getIntimateSofa");
button.addDescription(ACTIVITY, "kissIntimate");
else
print("activityPossible failed");
end;
else
print("nobody on sofa");
end
else
print("sender is user");
end
end )
-- sit on sofa
onMsg("sit", function(msg)
-- get the game object server
local gameObjectServer = getGameObjectServer();
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
-- if this is broken: abort characters action
if abortIfBroken(character) then return end;
-- walk to the closest action point
local actionPoint = character.getClosestFreeActionPointToClickPoint(this, {"sit1", "sit2", "sit3"});
if (actionPoint) then
local wso = character.walkSO;
-- create state machine contexts
local wsoContext = StateMachineContext();
-- store the action point
wsoContext.storeData("actionPointName", actionPoint.getName());
if (wso.walkToActionPoint(actionPoint)) then
wso.queueStateMachine("sofaChar.sitDown", this, wsoContext);
else
print("no path found");
instantAbort(character, EMOTICON_NOPATH, "emoThink")
end
else
print("no action point found");
instantAbort(character, EMOTICON_CANNOT, "emoThink")
end
end )
-- lay on sofa
onMsg("nap", function(msg)
-- get the game object server
local gameObjectServer = getGameObjectServer();
-- get the current character
local character = getStateObjectFromID(msg.sender);
-- if this is broken: abort characters action
if abortIfBroken(character) then return end;
-- walk to the action point
local actionPoint = character.getFreeActionPoint(this, "sit2");
if (actionPoint) then
-- get the walk state object
local wso = character.walkSO;
local wso = character.walkSO;
-- create state machine contexts
local wsoContext = StateMachineContext();
-- store the action point
wsoContext.storeData("actionPointName", actionPoint.getName());
if (wso.walkToActionPoint(actionPoint)) then
wso.queueStateMachine("sofaChar.layDown", this, wsoContext);
else
print("no path found");
instantAbort(character, EMOTICON_NOPATH, "emoThink")
end
else
print("no action point found");
instantAbort(character, EMOTICON_CANNOT, "emoThink")
end
end )
-- get intimate with a sofa occupant
onMsg("getIntimateSofa", function(msg)
local character = getStateObjectFromID(msg.sender);
local occupants = getOtherUsers(character, this, "sit")
if (getn(occupants) == 0) then
print("doublebed.lua::getIntimateBed no occupants found");
instantAbort(character, EMOTICON_CANNOT, "emoThink");
return
end
local occupant = occupants[1];
character.sendMsg("getIntimateSofa", occupant);
end )
-- repair
onMsg("repair", function(msg)
print("onMsg repair");
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
-- walk to the closest action point
local actionPoint = character.getFreeActionPoint(this, "repair");
-- get the walk state object
local wso = character.walkSO;
if (actionPoint) then
-- create state machine contexts
local wsoContext = StateMachineContext();
-- store the action point
wsoContext.storeData("actionPointName", actionPoint.getName());
if (wso.walkToActionPoint(actionPoint)) then
wso.queueStateMachine("repairChar.repairStart", this, wsoContext);
else
print("no path found");
instantAbort(character, EMOTICON_NOPATH, "emoThink")
end
else
print("no action point found");
instantAbort(character, EMOTICON_CANNOT, "emoThink")
end
end )
endStateMachine()